package com.manor.main.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.manor.common.bean.UserNBean;
import com.manor.common.utils.StringUtil;
import com.manor.main.R;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * @version 1.0
  
 * @date 2020/6/18  14:05
 */
public class GiftAdapter extends BaseQuickAdapter<UserNBean.GiftlistBean.ListBean, BaseViewHolder> {

    public GiftAdapter(int layoutResId, @Nullable List<UserNBean.GiftlistBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, UserNBean.GiftlistBean.ListBean item) {
        if (StringUtil.isNotEmpty(item.getName())) {
            Glide.with(getContext())
                    .load(item.getThumb())
//                    .apply(new RequestOptions().transform(new CenterCrop(),new CircleCrop()))
                    .apply(new RequestOptions().transform(new CenterCrop()))
                    .into((ImageView) helper.getView(R.id.iv_gift_img));
            helper.setText(R.id.iv_gift_text, item.getName() + " × " + item.getTotal_nums());
        } else {
            helper.setImageResource(R.id.iv_gift_img, R.mipmap.iv_no_gift);
            helper.setText(R.id.iv_gift_text, "暂未收到礼物");
        }

    }
}